{% extends "base.html" %}
{% block Content %}

    <div class="posts-container">
    {% if object_list %}
        {% for post in object_list %}
        <div class="post-item">
            <div onclick="location.href='{% url "post-detail" post.slug %}'" class="post-title">
                {{ post.title }} | {{ post.author }}
            </div>
            <div class="post-description">
                {{ post.body }}
            </div>
            <div class="post-date">
                {{ post.updated_at|date:"d M Y" }}
            </div>
            <div class="post-actions">
                <div class="post-item-isdone">
                    <button
                            class="btn btn-primary"
                            onclick="location.href='{% url "post-update" post.id %}'"
                            type="button">Редактировать</button>
                </div>
                <div class="todo-delete-item">
                    <button
                            onclick="location.href='{% url "post-delete" post.id %}'"
                            class="btn btn-danger" type="button">Удалить</button>
                </div>
            </div>

        </div>
    {% endfor %}
    {% else %}
        <div class="no-results">
            Пока не доблено ни одного поста...
        </div>
    {% endif %}
    <div class="post-add-new">
        <button
           class="btn btn-success"
           onclick="location.href='{% url "post-add" %}'"
           type="button">Добавить</button>
    </div>
</div>

{% endblock %}